package org.zfes.snowier.zbss.xzy.router.alert;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.zbss.xzy.biz.alert.model.AlertSubscribe;
import org.zfes.snowier.zbss.xzy.biz.alert.service.IAlertSubscribeService;
import org.zfes.snowier.core.data.SelectVo;
@Controller 
@RequestMapping("/xzy")
public class AlertSubscribeController implements BaseController {

	
	@Autowired
	private IAlertSubscribeService alertSubscribeService;
	
	//@RequiresPermissions(value="alertSubscribe:loadAlertSubscribeDataSet",desc="预警预警订阅列表")
    @RequestMapping(value="/loadAlertSubscribeDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadAlertSubscribeDataSet(@RequestBody Map<String,Object> params){
	    DataSet dataSet=  alertSubscribeService.loadAlertSubscribeDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
	//@RequiresPermissions(value="alertSubscribe:createAlertSubscribe",desc="预警预警订阅添加")
    @RequestMapping(value="/createAlertSubscribe", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public  @ResponseBody Object createAlertSubscribe(@RequestBody AlertSubscribe alertSubscribe){
		alertSubscribeService.createAlertSubscribe(alertSubscribe);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="alertSubscribe:loadAlertSubscribe",desc="预警预警订阅加载")
    @RequestMapping(value="/loadAlertSubscribe/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadAlertSubscribe(@PathVariable("id")Long id){
		Optional<AlertSubscribe> ops = alertSubscribeService.loadAlertSubscribeById(id);
		return ajaxQuery("alertSubscribe",ops);
    }
	
	//@RequiresPermissions(value="alertSubscribe:updateAlertSubscribe",desc="预警预警订阅更新")
    @RequestMapping(value="/updateAlertSubscribe", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object updateAlertSubscribe(@RequestBody  AlertSubscribe alertSubscribe){
		alertSubscribeService.updateAlertSubscribe(alertSubscribe);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="alertSubscribe:deletAlertSubscribe",desc="预警预警订阅删除")
    @RequestMapping(value="/deleteAlertSubscribe/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object deleteAlertSubscribe(@PathVariable("id")Long id){
		alertSubscribeService.deleteAlertSubscribe(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }


    @RequestMapping(value="/loadAlertSubscribeSelectVo", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadAlertSubscribeSelectVo(){
		 List<SelectVo>  ops = alertSubscribeService.loadAlertSubscribeSelectVo("");
		return ajaxQuery("selectVo",ops);
    }
    
}